package P103_Accessible;

import org.junit.Test;

import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;

/**
 * 反射访问属性或方法时将Accessible设置为true
 */
public class Accessible {

    public class Foo {

        public final void doStuff() {
            System.out.println("-------");
        }
    }

    @Test
    public void Test() throws InvocationTargetException, IllegalAccessException, NoSuchMethodException {
        Method method = Foo.class.getMethod("doStuff");
        boolean accessible = method.isAccessible();
        System.out.println("isAccessible:"+accessible);
        method.invoke(new Foo());
    }
}
